package com.business.system.official.toursism.websiteimage.manager.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.business.system.official.toursism.websiteimage.entity.WebsiteImage;
import com.business.system.official.toursism.websiteimage.manager.WebsiteImageManager;
import com.business.system.official.toursism.websiteimage.mapper.WebsiteImageMapper;
import com.business.system.official.toursism.websiteimage.vo.WebsiteImageBriefListVO;
import com.business.system.official.toursism.websiteimage.vo.WebsiteImageBriefVO;
import com.business.system.official.toursism.websiteimage.vo.WebsiteImageDetailListVO;
import com.business.system.official.toursism.websiteimage.vo.WebsiteImageDetailVO;
import com.business.system.official.toursism.websiteimage.vo.data.WebsiteImageBriefData;
import com.business.system.official.toursism.websiteimage.vo.data.WebsiteImageDetailData;
import com.seed.core.exception.ManagerException;
import com.seed.core.pojo.manager.impl.SeedSystemManagerImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * @description 轮播图
 * @author CodeGenerator
 * @date   2025-01-27
 * @version V1.0
 */
@Slf4j
@Transactional(rollbackFor = ManagerException.class)
@Service("websiteImageManager")
public class WebsiteImageManagerImpl extends SeedSystemManagerImpl<WebsiteImageMapper, WebsiteImage> implements WebsiteImageManager {

    /**
     * 根据id获取详情VO data
     *
     * @param websiteImageId 对象id
     * @return 详情VO data对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteImageDetailData convertDetailData(String websiteImageId) throws ManagerException {
        WebsiteImage websiteImage = this.getById(websiteImageId);
        return this.convertDetailData(websiteImage);
    }

    /**
     * 转换为VO对象
     *
     * @param websiteImage model
     * @return VO对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteImageDetailData convertDetailData(WebsiteImage websiteImage) throws ManagerException {
        WebsiteImageDetailData websiteImageDetailData = new WebsiteImageDetailData();
        try {
            BeanUtils.copyProperties(websiteImage, websiteImageDetailData);
        } catch (Exception e) {
            throw new ManagerException(e, websiteImage);
        }
        return websiteImageDetailData;
    }

    /**
     * 根据id获取详情VO
     *
     * @param websiteImageId 对象id
     * @return 详情VO对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteImageDetailVO getDetailVO(String websiteImageId) throws ManagerException {
        WebsiteImageDetailData websiteImageDetailData = this.convertDetailData(websiteImageId);
        return new WebsiteImageDetailVO(websiteImageDetailData);
    }

    /**
     * 根据对象获取详情VO
     *
     * @param websiteImage 对象
     * @return 详情VO对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteImageDetailVO getDetailVO(WebsiteImage websiteImage) throws ManagerException {
        WebsiteImageDetailData websiteImageDetailData = this.convertDetailData(websiteImage);
        return new WebsiteImageDetailVO(websiteImageDetailData);
    }

    /**
     * 根据对象ids获取详情VO data list
     *
     * @param ids 对象ids
     * @return 详情VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public List<WebsiteImageDetailData> getConvertDetailListVOByIds(List<String> ids) throws ManagerException {
        LambdaQueryWrapper<WebsiteImage> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(WebsiteImage::getId, ids);
        List<WebsiteImage> websiteImageList = this.list(queryWrapper);
        return this.listConvertDetailData(websiteImageList);
    }

    /**
     * 根据查询条件获取详情VO data list
     *
     * @param queryWrapper 查询条件
     * @return 详情VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public List<WebsiteImageDetailData> listConvertDetailData(Wrapper<WebsiteImage> queryWrapper) throws ManagerException {
        List<WebsiteImage> websiteImageList = this.list(queryWrapper);
        return this.listConvertDetailData(websiteImageList);
    }

    /**
     * 转换为VO对象
     *
     * @param websiteImageList model列表
     * @return VO对象列表
     * @throws ManagerException 通用层异常
     */
    @Override
    public List<WebsiteImageDetailData> listConvertDetailData(List<WebsiteImage> websiteImageList) throws ManagerException {
        List<WebsiteImageDetailData> websiteImageDetailDataList = new ArrayList<>();
        for (WebsiteImage websiteImage : websiteImageList) {
            websiteImageDetailDataList.add(this.convertDetailData(websiteImage));
        }
        return websiteImageDetailDataList;
    }

    /**
     * 根据对象ids获取详情VO data list
     *
     * @param ids 对象ids
     * @return 详情VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteImageDetailListVO getDetailListVOByIds(List<String> ids) throws ManagerException {
        return new WebsiteImageDetailListVO(this.getConvertDetailListVOByIds(ids));
    }

    /**
     * 根据查询条件获取详情VO data list
     *
     * @param queryWrapper 查询条件
     * @return 详情VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteImageDetailListVO getDetailListVO(Wrapper<WebsiteImage> queryWrapper) throws ManagerException {
        return new WebsiteImageDetailListVO(this.listConvertDetailData(queryWrapper));
    }

    /**
     * 根据对象list获取详情VO data list
     *
     * @param websiteImageList 对象list
     * @return 详情VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteImageDetailListVO getDetailListVO(List<WebsiteImage> websiteImageList) throws ManagerException {
        return new WebsiteImageDetailListVO(this.listConvertDetailData(websiteImageList));
    }

    /**
     * 根据id获取简略VO data
     *
     * @param websiteImageId 对象id
     * @return 简略VO data对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteImageBriefData convertBriefData(String websiteImageId) throws ManagerException {
        WebsiteImage websiteImage = this.getById(websiteImageId);
        return this.convertBriefData(websiteImage);
    }

    /**
     * 转换为VO对象
     *
     * @param websiteImage model
     * @return VO对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteImageBriefData convertBriefData(WebsiteImage websiteImage) throws ManagerException {
        WebsiteImageBriefData websiteImageBriefData = new WebsiteImageBriefData();
        try {
            BeanUtils.copyProperties(websiteImage, websiteImageBriefData);
        } catch (Exception e) {
            throw new ManagerException(e, websiteImage);
        }
        return websiteImageBriefData;
    }

    /**
     * 根据id获取简略VO
     *
     * @param websiteImageId 对象id
     * @return 简略VO对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteImageBriefVO getBriefVO(String websiteImageId) throws ManagerException {
        WebsiteImageBriefData websiteImageBriefData = this.convertBriefData(websiteImageId);
        return new WebsiteImageBriefVO(websiteImageBriefData);
    }

    /**
     * 根据对象获取简略VO
     *
     * @param websiteImage 对象
     * @return 简略VO对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteImageBriefVO getBriefVO(WebsiteImage websiteImage) throws ManagerException {
        WebsiteImageBriefData websiteImageBriefData = this.convertBriefData(websiteImage);
        return new WebsiteImageBriefVO(websiteImageBriefData);
    }

    /**
     * 根据对象ids获取简略VO data list
     *
     * @param ids 对象ids
     * @return 简略VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public List<WebsiteImageBriefData> listConvertBriefDataByIds(List<String> ids) throws ManagerException {
        LambdaQueryWrapper<WebsiteImage> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(WebsiteImage::getId, ids);
        List<WebsiteImage> websiteImageList = this.list(queryWrapper);
        return this.listConvertBriefData(websiteImageList);
    }

    /**
     * 根据查询条件获取简略VO data list
     *
     * @param queryWrapper 查询条件
     * @return 简略VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public List<WebsiteImageBriefData> listConvertBriefData(Wrapper<WebsiteImage> queryWrapper) throws ManagerException {
        List<WebsiteImage> websiteImageList = this.list(queryWrapper);
        return this.listConvertBriefData(websiteImageList);
    }

    /**
     * 转换为VO对象
     *
     * @param websiteImageList model列表
     * @return VO对象列表
     * @throws ManagerException 通用层异常
     */
    @Override
    public List<WebsiteImageBriefData> listConvertBriefData(List<WebsiteImage> websiteImageList) throws ManagerException {
        List<WebsiteImageBriefData> websiteImageBriefDataList = new ArrayList<>();
        for (WebsiteImage websiteImage : websiteImageList) {
            websiteImageBriefDataList.add(this.convertBriefData(websiteImage));
        }
        return websiteImageBriefDataList;
    }

    /**
     * 根据对象ids获取简略VO data list
     *
     * @param ids 对象ids
     * @return 简略VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteImageBriefListVO getBriefListVOByIds(List<String> ids) throws ManagerException {
        LambdaQueryWrapper<WebsiteImage> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(WebsiteImage::getId, ids);
        List<WebsiteImage> websiteImageList = this.list(queryWrapper);
        return new WebsiteImageBriefListVO(this.listConvertBriefData(websiteImageList));
    }

    /**
     * 根据查询条件获取简略VO data list
     *
     * @param queryWrapper 查询条件
     * @return 简略VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteImageBriefListVO getBriefListVO(Wrapper<WebsiteImage> queryWrapper) throws ManagerException {
        List<WebsiteImage> websiteImageList = this.list(queryWrapper);
        return new WebsiteImageBriefListVO(this.listConvertBriefData(websiteImageList));
    }

    /**
     * 根据对象list获取简略VO data list
     *
     * @param websiteImageList 对象list
     * @return 简略VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteImageBriefListVO getBriefListVO(List<WebsiteImage> websiteImageList) throws ManagerException {
        return new WebsiteImageBriefListVO(this.listConvertBriefData(websiteImageList));
    }
}
